Skip to content

Read GPP consent from the IAB's SharedPreferences keys - #49

Open
jrosendahl-opt wants to merge 1 commit into
masterfrom
fix/gpp-cmp-keys
Open

jrosendahl-opt wants to merge 1 commit into
masterfrom
fix/gpp-cmp-keys

Conversation

@jrosendahl-opt

@jrosendahl-opt jrosendahl-opt commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Why

The IAB GPP CMP API spec has in-app CMPs store the GPP string under IABGPP_HDR_GppString and the applicable section IDs under IABGPP_GppSID (underscore-separated, e.g. 2_7). The SDK read IABGPP_2_TCString, which isn't an IAB key, and never read the section IDs. With a spec-compliant CMP, no gpp was sent, and gpp_sid was never sent unless the app set OptableConsents.gppSid.

Same fix as the iOS SDK (Optable/optable-ios-sdk#86).

The IAB GPP CMP API spec has in-app CMPs store the GPP string under
IABGPP_HDR_GppString and the section IDs under IABGPP_GppSID
(underscore-separated). The SDK read IABGPP_2_TCString, which isn't an
IAB key, and never read the section IDs.

- Read IABGPP_HDR_GppString first, keep IABGPP_2_TCString as a fallback.
- Read IABGPP_GppSID and convert "2_7" to "2,7" for the Edge API.
- Use the CMP's section IDs only when the GPP string also came from the CMP.
- An explicit gppSid always wins.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
*/
fun getGppSid(): String? {
try {
return prefs.getString(KEY_GPP_SID, null)?.replace("_", ",")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the stored value is empty, this sends gpp_sid=. Should it return null when blank?

return customConsents.gppSid
}
// The CMP's section IDs are only used with the CMP's GPP string, never with a custom one.
if (customConsents.gpp == null && localStorage.getGppConsent() != null) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This also passes when the GPP string comes from the legacy key, so the CMP's section IDs get sent with a string the CMP didn't write. Should it only use them when IABGPP_HDR_GppString is set?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants